package com.example.building_inoutv1;

import java.util.List;

import Business.bSQL_Heper;
import Entities.EAccount_;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;

public class MainActivity extends Activity {

	bSQL_Heper b;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		b= new bSQL_Heper(this);
		/*
		 * kiem tra xem co insert duoc acount hay khong 
		 * */
		b.addAccount_(new EAccount_("TK1","Tran van b","Photo","2013/05/10","Ghi chu","1",1));
		b.addAccount_(new EAccount_("TK2","Nguyen Van b","Photo","2013/05/10","Ghi chu","1",1));
		b.addAccount_(new EAccount_("TK3","Nguyen Van C","Photo","2013/05/10","Ghi chu","1",1));
		b.addAccount_(new EAccount_("TK4","Nguyen Van d","Photo","2013/05/10","Ghi chu","1",1));
		b.addAccount_(new EAccount_("TK5","Nguyen Van e","Photo","2013/05/10","Ghi chu","1",1));
		/*
		 * kiem tra xem co delete duoc acount hay khong 
		 * */
		Log.d("Reading: ", "delete  contacts.. 1");
		b.deleteAccount_(1);
		/*
		 * kiem tra xem co Update duoc acount hay khong 
		 * */
		Log.d("Reading: ", "Up contacts..");
		EAccount_ v = new EAccount_();
		v.setAccountName("Tai Khoan Up");
		v.setdatepost("2013/05/27");
		v.setAvata("new avata");
		v.setflag("0");
		v.setAcoutID(2);
		b.updateAccount_(v);
		/*
		 * Doc du lieu tu table acount 
		 * */
		Log.d("Reading: ", "Reading all contacts..");
		
        List<EAccount_> contacts = b.getAllAccount_();       
 
        for (EAccount_ cn : contacts) {
            String log = "Id: "+cn.getAcoutID()+" ,Name: " + cn.getAccountName() +", Avata: " + cn.getAvata() + " ,Photo: " + cn.getPhoto() + " ,datepost: " + cn.getdatepost()+ " ,vnote: " + cn.getnote()+ " ,vflag: " + cn.getflag()+ " ,UserID: " + cn.getUserID();
                // Writing Contacts to log
        Log.d("Name: ", log);
        
        }
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
